Skip to content

Add powershell (windows) support#238

Open
cnukaus wants to merge 3 commits intomicrosoft:mainfrom
what-cloud:main
Open

Add powershell (windows) support#238
cnukaus wants to merge 3 commits intomicrosoft:mainfrom
what-cloud:main

Conversation

@cnukaus
Copy link
Copy Markdown

@cnukaus cnukaus commented Apr 9, 2026

Enhanced Powershell support:

I added Windows command resolution helpers, added codex detection, expanded the “no CLI found” message to include Codex, and changed npm-installed CLIs to prefer <name>.cmd on Windows before spawning.
That fixes the exact failure mode where PowerShell can run codex but child_process.spawn(\"codex\") cannot.

I also updated the CLI surface and docs, now advertises codex in --cli

@cnukaus
Copy link
Copy Markdown
Author

cnukaus commented Apr 9, 2026

@microsoft-github-policy-service agree

@Alan-Jowett
Copy link
Copy Markdown
Member

Thank you for this contribution, @cnukaus! 🎉 Adding Codex CLI support and fixing the Windows .cmd shim resolution issue with child_process.spawn() is a great improvement — this is a real pain point for Windows users.

The resolveSpawnCommand() approach is well thought out, the test coverage is solid, and the documentation updates are thorough. I've left a few review comments below — mostly around spec sync and a test edge case. Really appreciate you taking the time to submit this!

Copy link
Copy Markdown
Member

@Alan-Jowett Alan-Jowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for this well-structured PR! A few items to address before merge:

IMPLEMENTATION_PLAN.md — please remove (must fix)

This appears to be a development log from the implementation process. PromptKit doesn't maintain implementation plans at the repo root, and this would add noise to the project structure.

Spec files need codex added (should fix):

requirements.md has several references to the supported CLI list that need codex added:

  • REQ-CLI-010 — detection order (copilot → gh copilot → claude)
  • REQ-CLI-011 — valid --cli values (copilot, gh-copilot, claude)
  • REQ-CLI-017 — per-CLI spawn commands (missing codex entry)
  • ASSUMPTION-003 — accepted --cli values

validation.md should document the new TC-CLI-072A test case alongside existing TC-CLI-072.

assert.strictEqual(
parsedCmd,
`${cliName}.cmd`,
`${cliName} should spawn the Windows .cmd shim`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion will fail on Windows — which is ironic given the PR's intent! 😄

The dry-run test uses an empty PATH directory (emptyBinDir), so when resolveSpawnCommand() runs, it can't find any .cmd file and correctly falls back to the bare command name. But this assertion expects ${cliName}.cmd on Windows.

To fix, create a .cmd stub in emptyBinDir so resolveSpawnCommand() can find it:

// Create a .cmd stub so resolveSpawnCommand finds it
if (process.platform === "win32" && cliName !== "gh-copilot") {
  fs.writeFileSync(path.join(emptyBinDir, `${cliName}.cmd`), "");
}

Alternatively, accept the bare command name when no .cmd shim is present on PATH (since that is the correct resolveSpawnCommand behavior).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, this should have been fixed now.

(Unix) — this is the most reliable cross-platform way to check if a
command exists on PATH without actually executing it.
- The detection order (copilot → gh-copilot → claude) prioritizes GitHub
- The detection order (copilot → gh-copilot → claude → codex) prioritizes GitHub
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-existing nit (optional fix): This line says detection uses execFileSync with where/which, but the implementation was changed to use direct PATH scanning in a previous PR. Since you're editing this section anyway, it might be worth correcting. Totally optional — not something you introduced.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, please check these should have been fixed

@what-cloud
Copy link
Copy Markdown

Updated routing .cmd launches through cmd.exe in cli/lib/launch.js:67 while keeping
argument handling explicit, so it does not fall back to the old shell: true behavior.

The No supported LLM CLI found on PATH lines are still expected from the negative-path tests. The important part is that the spawn EINVAL should now be gone.

@Alan-Jowett
Copy link
Copy Markdown
Member

Hi @cnukaus / @what-cloud — thanks for the follow-up commits! A few items still need attention before we can merge:

  1. IMPLEMENTATION_PLAN.md — still present (must fix)
    This development log shouldn't live at the repo root. Please remove it from the PR.

  2. cli/specs/design.md line 148 — stale detection description
    The text still references execFileSync with where/which, but the implementation now uses direct PATH scanning. Since you're already editing this section, it would be great to correct this.

  3. cli/specs/requirements.md — character encoding corruption
    All em-dashes (, U+2014) in this file have been replaced with triple question marks (???, U+003F × 3) — 30 occurrences. This appears to be an editor or locale encoding issue. The base branch has the correct em-dashes; the PR branch has ??? in their place. The same issue also affects a few comments in cli/tests/launch.test.js.

    You can verify by searching for ??? in the file, or comparing the raw bytes against the upstream version.

Everything else looks good — the spec updates for codex, the test fixes, and the Windows .cmd shim logic are all solid. Just these three items to tidy up. Thanks again for the contribution! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants